<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    
<head>   
    
    
    <!--AdForward Begin:-->
<script type="text/javascript" ads-src="http://csdnim.allyes.com/main/s?user=allyestest|allyestest|allyestest0410&db=csdnim&border=0&local=yes&js=ie" src="http://creatim.allyes.com.cn/td/AllyesDeliver.min.js" charset="gbk"></script>
<!--AdForward End-->

<!--AdForward Begin:-->
<script type="text/javascript" ads-src="http://csdnim.allyes.com/main/s?user=csdn|homepage|floating_1&db=csdnim&border=0&local=yes&js=ie" src="http://creatim.allyes.com.cn/td/AllyesDeliver.min.js" charset="gbk"></script>
<!--AdForward End-->

<!--AdForward Begin:-->
<script type="text/javascript" ads-src="http://csdnim.allyes.com/main/s?user=csdn|homepage|WebIM_1&db=csdnim&border=0&local=yes&js=ie" src="http://creatim.allyes.com.cn/td/AllyesDeliver.min.js" charset="gbk"></script>
<!--AdForward End-->

     
    <script type="text/javascript" src="http://c.csdnimg.cn/pubfooter/js/tracking.js" charset="utf-8"></script>  

    <script type="text/javascript">
        var protocol = window.location.protocol;
        document.write('<script type="text/javascript" src="' + protocol + '//csdnimg.cn/pubfooter/js/repoAddr2.js?v=' + Math.random() + '"></' + 'script>');
    </script>

     <script id="allmobilize" charset="utf-8" src="http://a.yunshipei.com/46aae4d1e2371e4aa769798941cef698/allmobilize.min.js"></script>
 <meta http-equiv="Cache-Control" content="no-siteapp" /><link rel="alternate" media="handheld" href="#" />

    <title>JSONModel解析数据成Model - Jacky Shin的专栏
        - 博客频道 - CSDN.NET</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="这两个开源库都是用来进行封装JSON-&gt;Model的， 想想看， 直接向服务器发" />
    <script src="http://static.blog.csdn.net/scripts/jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="http://static.blog.csdn.net/scripts/ad.js?v=1.1"></script>
        <!--new top-->
               <link rel="stylesheet" href="http://static.csdn.net/public/common/toolbar/css/index.css">        <!--new top-->

    <link rel="Stylesheet" type="text/css" href="http://static.blog.csdn.net/skin/default/css/style.css?v=1.1" />
    <link id="RSSLink" title="RSS" type="application/rss+xml" rel="alternate" href="/smking/rss/list" />
    <link rel="shortcut icon" href="http://c.csdnimg.cn/public/favicon.ico" />
    <link type="text/css" rel="stylesheet" href="http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/default.css" />
 


</head>
<body>
    
   
      <!--new top-->
    <script id="toolbar-tpl-scriptId" fixed="true" prod="blog" skin="black" src="http://static.csdn.net/public/common/toolbar/js/html.js" type="text/javascript"></script>
     <!--new top-->
    <div id="container">
        <div id="header">
    <div class="header">
        <div id="blog_title">
            <h2>
                <a href="http://blog.csdn.net/smking">Jacky Shin的专栏</a></h2>
            <h3></h3>
            <div class="clear">
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
</div>
<div id="navigator">
    <div class="navigator_bg">
    </div>
    <div class="navigator">
        <ul>
            
                <li id="btnContents"><a href="http://blog.csdn.net/smking?viewmode=contents"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_mulu'])">
                    <img src="http://static.blog.csdn.net/images/ico_list.gif">目录视图</span></a></li>
                <li id="btnView"><a href="http://blog.csdn.net/smking?viewmode=list"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_zhaiyao'])">
                    <img src="http://static.blog.csdn.net/images/ico_summary.gif">摘要视图</span></a></li>
                <li id="btnRss"><a href="http://blog.csdn.net/smking/rss/list"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_RSS'])">
                    <img src="http://static.blog.csdn.net/images/ico_rss.gif">订阅</span></a></li>                

            </ul>
    </div>
</div>
<script type="text/javascript">
    var username = "smking";
    var _blogger = username;
    var blog_address = "http://blog.csdn.net/smking";
    var static_host = "http://static.blog.csdn.net";
    var currentUserName = "";  
</script>

        <div id="body">
            <div id="main">
                <div class="main">
                        <div class="ad_class">
<div class="notice tracking-ad" data-mod='popu_3' > 

<a href="http://www.csdn.net/app/"><font color=blue>
CSDN Android客户端 正式发布</font></a>
&nbsp;&nbsp;&nbsp;


<a href="http://blog.csdn.net/blogdevteam/article/details/45846519">
<font color=red>扒一扒你遇到过最NB开发项目</font></a>
&nbsp;&nbsp;&nbsp;



<a href="http://bbs.csdn.net/topics/391037747">
<font color=blue>5月问答又送C币咯！
</font></a>
&nbsp;&nbsp;&nbsp;



<a href="http://huiyi.csdn.net/activity/product/goods_list?project_id=1951">
<font color=red>Hadoop实战高手速成宝典
</font></a>
&nbsp;&nbsp;&nbsp;</div>                        </div>
                        

  
<link href="http://static.blog.csdn.net/css/comment1.css" type="text/css" rel="stylesheet" />
<link href="http://static.blog.csdn.net/css/style1.css" type="text/css" rel="stylesheet" />
<script language='JavaScript' type='text/javascript' src='http://download.csdn.net/js/jquery.cookie.js'></script>
<script type="text/javascript" src="http://c.csdnimg.cn/rabbit/search-service/main.js"></script>


<link rel="stylesheet" href="http://static.blog.csdn.net/public/res-min/markdown_views.css?v=1.0" />

<script type="text/javascript" src="http://static.blog.csdn.net/public/res/bower-libs/MathJax/MathJax.js?config=TeX-AMS_HTML"></script>









  <script type="text/ecmascript">
      window.quickReplyflag = true;
    </script>
<div id="article_details" class="details">
    <div class="article_title">   
         <span class="ico ico_type_Original"></span>


    <h1>
        <span class="link_title"><a href="/smking/article/details/40432287">
        JSONModel解析数据成Model
        </a></span>
    </h1>
</div>

    <div class="article_manage">
        <span class="link_categories">
        分类：
            <a href="/smking/article/category/585876" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_fenlei']);">技术</a> 
        </span>
    <span class="link_postdate">2014-10-24 20:45</span>
    <span class="link_view" title="阅读次数">6794人阅读</span>
    <span class="link_comments" title="评论次数"><a href="#comments" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_pinglun'])">评论</a>(0)</span>
    <span class="link_collect"><a href="javascript:void(0);" onclick="javascript:_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shoucang']);collectArticle('JSONModel解析数据成Model','40432287');return false;" title="收藏">收藏</a></span>
    <span class="link_report"><a href="#report"  onclick="javascript:_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_jubao']);report(40432287,2);return false;" title="举报">举报</a></span>
    
</div>

  
    
<div id="article_content" class="article_content">

<p>JSONModel， Mantle</p>
<p>这两个开源库都是用来进行封装JSON-&gt;Model的， 想想看， 直接向服务器发起一个请求，然后回来后，就是一个Model， 直接使用， 这是一个多么美好的事情。 感谢GitHub的开源精神。</p>
<p><br>
</p>
<p>那我们开始吧。&nbsp;</p>
<p>先说说这两个的差别。</p>
<p>这两个使用的方法其实都差不多， 详细的使用方法请直接GitHub上找， 还是比较简单地。 就我个人来说JSONModel相对起来使用较为简单，而Mantle使用起来略为复杂，但是Mantle&#20284;乎比JSONModel更为强大。&nbsp;</p>
<p>一般的项目，其实使用JSONModel就已经足够。&nbsp;</p>
<p><br>
</p>
<p>&nbsp;下面讲一下JSONModel的使用方法。&nbsp;</p>
<p>@inteface MyModel : JSONModel</p>
<p><br>
</p>
<p>1. 使用JSONModel时，不需要额外去检查所要的服务器属性是否有返回。JSONModel的initWithDictionary方法会自动去进行检查并处理。</p>
<p><br>
</p>
<p>2. 有效性检查，如果指定的服务器返回的某个字段没有返回，而且又是必须的， 像下面这样写，则会抛出异常。</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(0,143,0)">
//this property is required</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) NSString* string;</span></p>
因为默认这个&#20540;是必须的。
<p></p>
<p><br>
</p>
<p>一般情况下，我们不想因为服务器的某个&#20540;没有返回就使程序崩溃， 我们会加关键字Optional.</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(0,143,0)">
//this one's optional</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@property</span> (<span style="color:#0433ff">strong</span>,
<span style="color:#0433ff">nonatomic</span>) NSNumber&lt;Optional&gt;* number;</p>
<p><br>
</p>
<p></p>
<p>3. 原子数据， 之前可能是如下面这样操作数据</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">if</span> (jsonDict[<span style="color:#b4261a">@&quot;name&quot;</span>])</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">labelName.text = jsonDict[<span style="color:#b4261a">@&quot;name&quot;</span>];</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
else</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">[<span style="color:#0433ff">self</span> showErrorMessageAndBailout];</p>
<p><br>
</p>
这段代码会使得jsonDict[@&quot;name&quot;], 会被读取，然后进行有效性判断，最后再被使用。 换句话来说，这里使用了三次， 而如果某些情况下，使用一次就已经出错，但却无法阻止它接下来的连续出错。
<p></p>
<p>而如果使用JSONModel的属性，则只会保证上面只使用一次，就可以进行有效性的判断以及使用。（其实上面也可以做到，只需要把这个&#20540;取出来，存下来接着使用却可，但是代码会稍显麻烦）</p>
<p>同时读取一批数据如下面代码：</p>
<p>简单模型如下：</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">SimpleModel* model = [[SimpleModel alloc] initWithString:<span style="color:#b4261a">@&quot;...json here...&quot;</span> error:<span style="color:#0433ff">nil</span>];</p>
<div><br>
</div>
<br>
<pre class="objc" style="font-size:17px; line-height:17px; background-color:rgb(239,239,239)"></pre>
<p>复杂模型如下， 这里假设复杂模型包含了简单模型。主要是为了说明模型之前的包含情况下，照样可以进行解析。</p>
<p></p>
<pre class="objc" style="font-size:17px; line-height:17px; background-color:rgb(239,239,239)"></pre>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">SuperComplicatedModel* model = [[SuperComplicatedModel alloc] initWithString:<span style="color:#b4261a">@&quot;...json here...&quot;</span> error:<span style="color:#0433ff">nil</span>];</p>
<div><br>
</div>
模型的批处理，即一次可以处理一批模型。
<p></p>
<p></p>
<pre class="objc" style="font-size:17px; line-height:17px; background-color:rgb(239,239,239)"></pre>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#3495af">NSArray</span>* models = [SuperComplicatedModel arrayOfObjectsFromDictionaries: jsonDatas error:<span style="color:#0433ff">nil</span>];</p>
<div></div>
<p></p>
<p></p>
<p>4. 数据转换, OC &lt;-&gt; JSON</p>
<p>注意下面这张图：这意味着JSON的数据&#26684;式只有中间的部分, string,number, array, object, 以及null</p>
<img src="http://www.touch-code-magazine.com/img/json.png" alt="" style="margin-top:30px; margin-bottom:30px; border:1px solid gray">
<p>例如有如下 ＪＳＯＮ数据：</p>
<p></p>
<pre lang="json" style="font-size:17px; line-height:17px; background-color:rgb(239,239,239)"></pre>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;<span style="color:#b4261a">&quot;first&quot;</span> : 1,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;<span style="color:#b4261a">&quot;second&quot;</span>: 35,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;<span style="color:#b4261a">&quot;third&quot;</span> : 10034,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;<span style="color:#b4261a">&quot;fourth&quot;</span>: 10000</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<div><br>
</div>
可以如下定义这个模型
<p></p>
<p></p>
<pre class="objc" style="font-size:17px; line-height:17px; background-color:rgb(239,239,239)"><span style="color:rgb(166,19,144)"></span></pre>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> NumbersModel:<span style="color:#3495af">JSONModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,</span>nonatomic<span style="color:#000000">)
</span>short<span style="color:#000000"> first;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,</span>nonatomic<span style="color:#000000">)
</span>double<span style="color:#000000"> second;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,</span>nonatomic<span style="color:#000000">)
</span><span style="color:#3495af">NSNumber</span><span style="color:#000000">* third;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,</span>nonatomic<span style="color:#000000">)
</span><span style="color:#3495af">NSString</span><span style="color:#000000">* fourth;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
注：JSON数据中， first为1,second为35, 但是它们却可以自动被转换成short， double类型。 对于10034, 以及10000会自动转换为NSNumber以及NSString。 这些都是JSONModel会自动进行的。 神奇吧！
<p></p>
<p><br>
</p>
<p>5. 内嵌的数据转换， 在JSONValueTransformer类中，有各种内嵌的转换支持。如下面</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;purchaseDate&quot;<span style="color:#000000"> :
</span>&quot;2012-11-26T10:00:01&#43;02:00&quot;<span style="color:#000000">,</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;blogURL&quot;<span style="color:#000000"> : </span>
&quot;http://www.touch-code-magazine.com&quot;</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<p><br>
</p>
<p>分别是一个 日期类型，以及一个URL类型。</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> SmartModel:
<span style="color:#3495af">JSONModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span><span style="color:#3495af">NSDate</span><span style="color:#000000">* purchaseDate;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span><span style="color:#3495af">NSURL</span><span style="color:#000000">* blogUrl;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<br>
<pre class="objc" style="font-size:17px; line-height:17px; background-color:rgb(239,239,239)"><span style="color:rgb(166,19,144)"></span></pre>
用上面这个模型，不需要其它代码，即可以得到想要的转换 。
<p></p>
<p>这个JSONValueTransformer类中有如下支持的转换</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
NSMutableString &lt;-&gt; NSString</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
NSMutableArray &lt;-&gt; NSArray</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
NS(Mutable)Array &lt;- JSONModelArray</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
NSMutableDictionary &lt;-&gt; NSDictionary</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
NSSet &lt;-&gt; NSArray</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
BOOL &lt;-&gt; number/string</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
string &lt;-&gt; number</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
string &lt;-&gt; url</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
string &lt;-&gt; time zone</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
string &lt;-&gt; date</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
number &lt;-&gt; date</p>
<br>
<p>6. 自定义数据转换， 显然上面的内嵌转换有时不能满足我们的需要，所以我们需要如下的自定义转换。</p>
<p>你需要做的就是自定义一个JSONValueTransformer的类别文件，如下：</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> JSONValueTransformer(UIColor)</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">-(UIColor*)UIColorFromNSString:(<span style="color:#3495af">NSString</span>*)string;</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">-(<span style="color:#0433ff">id</span>)JSONObjectFromUIColor:(UIColor*)color;</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<br>
<p><br>
</p>
然后再进行实现即可。
<p></p>
<p>注意上面的命名是采用：</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">-(YourPropertyClass*)YourPropertyClassFromJSONObjectClass:(JSONObjectClass*)name;</p>
<div><br>
</div>
<br>
<p>例如：</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">-(UIColor*)UIColorFromNSString:(NSString*)string;</p>
<div><br>
</div>
<p>而要把这个类型转换为JSON，则像这样即可：（注下面这个id，可以修改也可以不用修改成NSString，因为一定知道这是一个nsstirng. &nbsp;heqin:这里其实也可能会是其它类的，应该是根据特定情况来特定判断。）</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">-(<span style="color:#0433ff">id</span>)JSONObjectFromYourPropertyClass:(YourPropertyClass*)color;</p>
<div><br>
</div>
<p></p>
<p>如下是另一个例子：</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@implementation</span> JSONValueTransformer (CustomTransformer)</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">- (<span style="color:#3495af">NSDate</span> *)NSDateFromNSString:(<span style="color:#3495af">NSString</span>*)string {</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(52,149,175)">
<span style="color:#000000">&nbsp; &nbsp; </span>NSDateFormatter<span style="color:#000000"> *formatter = [[</span>NSDateFormatter<span style="color:#000000">
</span>alloc<span style="color:#000000">] </span>init<span style="color:#000000">];</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; [formatter setDateFormat:APIDateFormat];</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;
<span style="color:#0433ff">return</span> [formatter <span style="color:#3495af">
dateFromString</span>:string];</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">- (<span style="color:#3495af">NSString</span> *)JSONObjectFromNSDate:(<span style="color:#3495af">NSDate</span> *)date {</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(52,149,175)">
<span style="color:#000000">&nbsp; &nbsp; </span>NSDateFormatter<span style="color:#000000"> *formatter = [[</span>NSDateFormatter<span style="color:#000000">
</span>alloc<span style="color:#000000">] </span>init<span style="color:#000000">];</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; [formatter setDateFormat:APIDateFormat];</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;
<span style="color:#0433ff">return</span> [formatter <span style="color:#3495af">
stringFromDate</span>:date];</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<br>
<p></p>
<p><br>
</p>
<p>7. 层级嵌套。</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;idImage&quot;<span style="color:#000000">: 1,</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;name&quot;<span style="color:#000000">: </span>
&quot;house.jpg&quot;<span style="color:#000000">,</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;copyright&quot;<span style="color:#000000">: {</span>&quot;author&quot;<span style="color:#000000">:</span>&quot;Marin Todorov&quot;<span style="color:#000000">,
</span>&quot;year&quot;<span style="color:#000000">:2012}</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<br>
<div>可以先定义如下的模型</div>
<div>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> CopyModel:
<span style="color:#3495af">JSONModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span><span style="color:#3495af">NSString</span><span style="color:#000000">* author;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>int<span style="color:#000000"> year;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<div><br>
</div>
</div>
<div>然后再定义模型：</div>
<div>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#0433ff">#import </span>&quot;CopyModel.h&quot;</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> ImageModel:
<span style="color:#3495af">JSONModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>int<span style="color:#000000"> idImage;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span><span style="color:#3495af">NSString</span><span style="color:#000000">* name;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@property</span> (<span style="color:#0433ff">strong</span>,
<span style="color:#0433ff">nonatomic</span>) CopyModel* copyright;</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<br>
</div>
<span style="font-family:Times; font-size:17px; line-height:17px; background-color:rgb(239,239,239)"></span>然后在你得到的ImageModel后， 就会发现其中的CopyModel也有数据了。&nbsp;
<p></p>
<p>如果你想要一个数组的模型属性，如下即可。</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@property</span> (<span style="color:#0433ff">strong</span>,
<span style="color:#0433ff">nonatomic</span>) NSArray&lt;TweetModel&gt;* tweets;</p>
<div><br>
</div>
<br>
<p></p>
<p>8. JSONModel转换为Dictioanry, JSONString.&nbsp;</p>
<p>直接使用JSONModel的方法toDictioanry, 以及toJSONString即可。</p>
<p><br>
</p>
<p>9. 保存model数据</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#3495af">NSDictionary</span>* object = [NSDictionary dictionaryWithContentsOfFile:filePath];</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">data = [[MyDataModel alloc] initWithDictionary: object];</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:'Heiti SC Light'; color:rgb(0,143,0)">
<span style="font-family:Menlo">//</span>保存操作</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">[[data toDictionary] writeToFile:filePath atomically:<span style="color:#0433ff">YES</span>];</p>
<div><br>
</div>
<br>
<p>10. Key mapping， 有时， 得到的数据不是在一个层级，如下：</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;
<span style="color:#b4261a">&quot;order_id&quot;</span>: 104,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;order_details&quot;<span style="color:#000000"> : [</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">&quot;name&quot;</span>: <span style="color:#b4261a">&quot;Product#1&quot;</span>,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">&quot;price&quot;</span>: {</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">&quot;usd&quot;</span>: 12.95</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<div><br>
</div>
<br>
<p>其中的order_id与name就不是一个层级，但我们仍然想在一个model中得到它们的数据。 如下：</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> OrderModel :
<span style="color:#3495af">JSONModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>int<span style="color:#000000">
</span>id<span style="color:#000000">;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>float<span style="color:#000000"> price;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span><span style="color:#3495af">NSString</span><span style="color:#000000">* productName;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@implementation<span style="color:#000000"> OrderModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&#43;(<span style="color:#3495af">JSONKeyMapper</span>*)keyMapper</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(52,149,175)">
<span style="color:#000000">&nbsp; &nbsp; </span><span style="color:#0433ff">return</span><span style="color:#000000"> [[</span>JSONKeyMapper<span style="color:#000000">
</span>alloc<span style="color:#000000">] </span>initWithDictionary<span style="color:#000000">:@{</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">@&quot;order_id&quot;</span>: <span style="color:#b4261a">@&quot;id&quot;</span>,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">@&quot;order_details.name&quot;</span>: <span style="color:#b4261a">
@&quot;productName&quot;</span>,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">@&quot;order_details.price.usd&quot;</span>: <span style="color:#b4261a">
@&quot;price&quot;</span><span style="white-space:pre"> </span><span style="color:#008f00">//
</span><span style="font-family:'Heiti SC Light'; color:rgb(0,143,0)">这里就采用了</span><span style="color:#008f00">KVC</span><span style="font-family:'Heiti SC Light'; color:rgb(0,143,0)">的方式来取&#20540;，它赋给</span><span style="color:#008f00">price</span><span style="font-family:'Heiti SC Light'; color:rgb(0,143,0)">属性</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }];</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<div><br>
</div>
<br>
<p><br>
</p>
<p>11. 全局Global key mapping. (使所有的模型都具备)， 个人觉得这个并不是非常通用，因为如果真是需要所有模型都具备这个keyMapper的转换，则直接继承一个基类就行了。</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">[JSONModel setGlobalKeyMapper:[</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [JSONKeyMapper alloc] initWithDictionary:@{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">@&quot;item_id&quot;</span>:<span style="color:#b4261a">@&quot;ID&quot;</span>,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">@&quot;item.name&quot;</span>: <span style="color:#b4261a">@&quot;itemName&quot;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }]</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;];</p>
<br>
<p>12. 自动把下划线方式的命名转为驼峰命名属性。还有类&#20284;的，如大写转为小写的方法：<span style="font-family:Menlo; font-size:13px">mapperFromUpperCaseToLowerCase<br>
</span></p>
<p><span style="font-family:Menlo; font-size:13px"></span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;
<span style="color:#b4261a">&quot;order_id&quot;</span>: 104,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;order_product&quot;<span style="color:#000000"> :
</span>@&quot;Product#1&quot;<span style="color:#000000">,</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;order_price&quot;<span style="color:#000000"> : 12.95</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<br>
<p>生成的模型</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> OrderModel :
<span style="color:#3495af">JSONModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>int<span style="color:#000000"> orderId;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>float<span style="color:#000000"> orderPrice;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span><span style="color:#3495af">NSString</span><span style="color:#000000">* orderProduct;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@implementation<span style="color:#000000"> OrderModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&#43;(<span style="color:#3495af">JSONKeyMapper</span>*)keyMapper</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(52,149,175)">
<span style="color:#000000">&nbsp; &nbsp; </span><span style="color:#0433ff">return</span><span style="color:#000000"> [</span>JSONKeyMapper<span style="color:#000000">
</span>mapperFromUnderscoreCaseToCamelCase<span style="color:#000000">];</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<br>
<p>13. 可选属性，建议尽量使用这种方式来避免异常。</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;id&quot;<span style="color:#000000">: </span>&quot;123&quot;<span style="color:#000000">,</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;
<span style="color:#b4261a">&quot;name&quot;</span>: null,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;
<span style="color:#b4261a">&quot;price&quot;</span>: 12.95</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<div><br>
</div>
<p></p>
<p>生成的模型如下：</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> ProductModel :
<span style="color:#3495af">JSONModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>int<span style="color:#000000">
</span>id<span style="color:#000000">;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span><span style="color:#3495af">NSString</span><span style="color:#000000">&lt;</span><span style="color:#3495af">Optional</span><span style="color:#000000">&gt;* name;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>float<span style="color:#000000"> price;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span><span style="color:#3495af">NSNumber</span><span style="color:#000000">&lt;</span><span style="color:#3495af">Optional</span><span style="color:#000000">&gt;* uuid;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@implementation<span style="color:#000000"> ProductModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<br>
通过上面的optional的方式， 我们可以给这个类添加一个isSuccess方法，该方法中判断name和uuid是否存在来决定是否从服务器成功取数据。 而不是把这两个属性设置为required，可以有效避免异常。
<p></p>
<p><br>
</p>
<p>14. Ignore属性， 会使得解析时会完全忽略它。 一般情况下，忽略的属性主要用在该&#20540;不从服务器获取，而是通过后面的代码进行设置。</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;id&quot;<span style="color:#000000">: </span>&quot;123&quot;<span style="color:#000000">,</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;
<span style="color:#b4261a">&quot;name&quot;</span>: null</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<br>
<p>模型为：</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> ProductModel :
<span style="color:#3495af">JSONModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>int<span style="color:#000000">
</span>id<span style="color:#000000">;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@property</span> (<span style="color:#0433ff">strong</span>,
<span style="color:#0433ff">nonatomic</span>) <span style="color:#3495af">NSString</span>&lt;<span style="color:#3495af">Ignore</span>&gt;* customProperty;</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@implementation<span style="color:#000000"> ProductModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<br>
<p>可以用下面方法，使当前类的全部属性都为可选，官网上说尽量避免这样的使用， （个人觉得官网的意思是指，尽量避免用来面方法来指定所有的属性为可选，即使要全部属性为可选，也尽量是在每个属性那里标注为Optional）</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@implementation<span style="color:#000000"> ProductModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&#43;(<span style="color:#0433ff">BOOL</span>)propertyIsOptional:(<span style="color:#3495af">NSString</span>*)propertyName</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
<span style="color:#000000">&nbsp; &nbsp; </span>return<span style="color:#000000"> </span>
YES<span style="color:#000000">;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<br>
<p>15. 延迟加载， 这种比较推荐，可以减少在网络读取时的性能消耗：关键字为： ConvertOnDemand</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">{</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;
<span style="color:#b4261a">&quot;order_id&quot;</span>: 104,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp;
<span style="color:#b4261a">&quot;total_price&quot;</span>: 103.45,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(180,38,26)">
<span style="color:#000000">&nbsp; &nbsp; </span>&quot;products&quot;<span style="color:#000000"> : [</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">&quot;id&quot;</span>: <span style="color:#b4261a">&quot;123&quot;</span>,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">&quot;name&quot;</span>: <span style="color:#b4261a">&quot;Product #1&quot;</span>,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">&quot;price&quot;</span>: 12.95</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">&quot;id&quot;</span>: <span style="color:#b4261a">&quot;137&quot;</span>,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">&quot;name&quot;</span>: <span style="color:#b4261a">&quot;Product #2&quot;</span>,</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#b4261a">&quot;price&quot;</span>: 82.95</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ]</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">}</p>
<br>
<p>使用模型：</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@protocol</span> ProductModel</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> ProductModel :
<span style="color:#3495af">JSONModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>int<span style="color:#000000">
</span>id<span style="color:#000000">;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>strong<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span><span style="color:#3495af">NSString</span><span style="color:#000000">* name;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>float<span style="color:#000000"> price;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@implementation<span style="color:#000000"> ProductModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo"><span style="color:#0433ff">@interface</span> OrderModel :
<span style="color:#3495af">JSONModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>int<span style="color:#000000"> order_id;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@property<span style="color:#000000"> (</span>assign<span style="color:#000000">,
</span>nonatomic<span style="color:#000000">) </span>float<span style="color:#000000"> total_price;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(52,149,175)">
<span style="color:#0433ff">@property</span><span style="color:#000000"> (</span><span style="color:#0433ff">strong</span><span style="color:#000000">,
</span><span style="color:#0433ff">nonatomic</span><span style="color:#000000">) </span>
NSArray<span style="color:#000000">&lt;</span>ProductModel<span style="color:#000000">,
</span>ConvertOnDemand<span style="color:#000000">&gt;* products;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@implementation<span style="color:#000000"> OrderModel</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(4,51,255)">
@end</p>
<br>
<p>16. 使用JSONHttpClient进行请求。&nbsp;</p>
<p></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(0,143,0)">
//add extra headers</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">[[JSONHTTPClient requestHeaders] setValue:<span style="color:#b4261a">@&quot;MySecret&quot;</span> forKey:<span style="color:#b4261a">@&quot;AuthorizationToken&quot;</span>];</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
<br>
</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; color:rgb(0,143,0)">
//make post, get requests</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">[JSONHTTPClient postJSONFromURLWithString:<span style="color:#b4261a">@&quot;http://mydomain.com/api&quot;</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params:@{<span style="color:#b4261a">@&quot;postParam1&quot;</span>:<span style="color:#b4261a">@&quot;value1&quot;</span>}</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; completion:^(<span style="color:#0433ff">id</span> json, JSONModelError *err) {</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<span style="color:#008f00">//check err, process json ...</span></p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo; min-height:15px">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>
<p style="margin-top:0px; margin-bottom:0px; font-size:13px; font-family:Menlo">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }];</p>
<p><br>
</p>
<p>好了， 所以的JSONModel的使用方法都已经在这里了， 综合了官网的使用方法。&nbsp;</p>
<p><br>
</p>
</div>




<!-- Baidu Button BEGIN -->

<div class="bdsharebuttonbox" style="float: right;">
<a href="#" class="bds_more" data-cmd="more" style="background-position:0 0 !important; background-image: url(http://bdimg.share.baidu.com/static/api/img/share/icons_0_16.png?v=d754dcc0.png) !important"></a>
<a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"  style="background-position:0 -52px !important"></a>
<a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"style="background-position:0 -104px !important"></a>
<a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"style="background-position:0 -260px !important"></a>
<a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"style="background-position:0 -208px !important"></a>
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"style="background-position:0 -1612px !important" ></a>
</div>
<script>window._bd_share_config = { "common": { "bdSnsKey": {}, "bdText": "", "bdMini": "1", "bdMiniList": false, "bdPic": "", "bdStyle": "0", "bdSize": "16" }, "share": {} }; with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];</script>
<!-- Baidu Button END -->

<!--172.16.140.11-->
<ul class="article_next_prev">
            <li class="prev_article"><span  onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shangyipian']);location.href='/smking/article/details/39646105';">上一篇</span><a href="/smking/article/details/39646105" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shangyipian'])">Coretext用法， 讲得很好。</a></li>
            <li class="next_article"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_xiayipian']);location.href='/smking/article/details/42212695';">下一篇</span><a href="/smking/article/details/42212695" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_xiayipian'])">一个优化过的OC的简单冒泡排序算法</a></li>
</ul>

<!-- Baidu Button BEGIN -->
<script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=1536434" ></script>
<script type="text/javascript" id="bdshell_js"></script>
<script type="text/javascript">
    document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
</script>
<!-- Baidu Button END -->


</div>
      <dl class="blog-associat-tag">
        <dt>主题推荐</dt>
        <dd>
                <a href="http://www.csdn.net/tag/数据" target="_blank" class="blog-tage-red" >数据</a> 
                <a href="http://www.csdn.net/tag/nsmutablearray" target="_blank" class="blog-tage-red" >nsmutablearray</a> 
                <a href="http://www.csdn.net/tag/服务器" target="_blank" class="blog-tage-red" >服务器</a> 
                <a href="http://www.csdn.net/tag/批处理" target="_blank" class="blog-tage-red" >批处理</a> 
                <a href="http://www.csdn.net/tag/异常" target="_blank" class="blog-tage-red" >异常</a> 
        </dd>
    </dl> 

<style>
.blog-ass-articl dd {
color: #369;
width: 99%; /*修改行*/
float: left;
overflow: hidden;
font: normal normal 12px/23px "SimSun";
height: 23px;
margin: 0;
padding: 0 0 0 10px;
margin-right: 30px;
background: url(../images/blog-dot-red3.gif) no-repeat 0 10px;
}

</style>

<dl class="blog-ass-articl" id="res-relatived" > 
     <dt><span>猜你在找</span></dt>    

     <div id="res"  data-mod="popu_36"  class="tracking-ad" style="width: 42%;float: left;margin-right: 30px;"></div>

   


    <div id="adCollege" style="width: 42%;float: left;"> 
        <script src="http://csdnimg.cn/jobreco/job_reco.js" type="text/javascript"></script> 
        <script type="text/javascript">
            csdn.position.showEdu({
                sourceType: "blog",
                searchType: "detail",
                searchKey: "40432287",
                username: "",
                recordcount: "5",
                containerId: "adCollege" //容器DIV的id。 
            });
        </script> 
    </div>  
   
</dl>

<div id="job_blog_reco">
<script src="http://c.csdnimg.cn/jobreco/job_reco.js" type="text/javascript"></script>
   
     <script type="text/javascript">
         csdn.position.show({
         sourceType: "blog",
         tplType: "blogDetail",
         searchType: "detail",
         searchKey: "40432287",
             username: "",
         containerId: "job_blog_reco"
        }); 
    </script>

</div>

<script type="text/javascript">
    var searchtitletags = 'JSONModel解析数据成Model' + ',' + '数据,nsmutablearray,服务器,批处理,异常';
    searchService({
        index: 'blog',
        query: searchtitletags,
        from: 5,
        size: 5,
        appendTo: '#res',
        url: 'recommend',
        his: 2,
        client: "blog_cf_enhance",
        tmpl: '<dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="#{ url }" title="#{ title }" strategy="#{ strategy }">#{ title }</a></dd>'
    });

 </script>   



    <div id="ad_cen">
   
          <script type="text/javascript">
              new Ad(4, 'ad_cen');
          </script>
    </div>
<div class="comment_class">
    <div id="comment_title" class="panel_head">
        <span class="see_comment">查看评论</span><a name="comments"></a></div>
    <div id="comment_list">
    </div>
    <div id="comment_bar">
    </div>
    <div id="comment_form">
    </div>

    <div class="announce">
        * 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场<a name="reply"></a><a name="quote"></a></div>
</div>

<script type="text/javascript">
    var fileName = '40432287';
    var commentscount = 0;
    var islock = false
</script>
<script type="text/javascript" src="http://static.blog.csdn.net/scripts/comment.js"></script>
    <div id="ad_bot">
    </div>
    <script type="text/javascript">
    new Ad(5, 'ad_bot');
    </script>
<div id="report_dialog">
</div>

<div id="d-top"  style="bottom:60px;">
        <a id="quick-reply" class="btn btn-top q-reply" title="快速回复" style="display:none;">
            <img src="http://static.blog.csdn.net/images/blog-icon-reply.png" alt="快速回复">
        </a>    

    <a id="d-top-a" class="btn btn-top backtop"  style="display: none;" title="返回顶部" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_huidaodingbu'])" style="">         
         <img src="http://static.blog.csdn.net/images/top.png" alt="TOP">
    </a>
</div>
<script type="text/javascript">
    $(function ()
    {
        $("#ad_frm_0").height("90px");
        
        setTimeout(function(){
            $("#ad_frm_2").height("200px");
        },1000);
        
        /*
        if($("#comment_content").length>0)
        {
            $("#quick-reply").show();

            $("#quick-reply").click(function(){
                setEditorFocus();
            });
        }       
     
        var d_top = $('#d-top-a');

        document.onscroll = function ()
        {
            var scrTop = (document.body.scrollTop || document.documentElement.scrollTop);
            if (scrTop > 500)
            {
                d_top.show();
            } else
            {
                d_top.hide();
            }
        }
        $('#d-top-a').click(function ()
        {
            scrollTo(0, 0);
            this.blur();
            return false;
        });
        */
    });
  
</script>
<style type="text/css">
    .tag_list
    {
        background: none repeat scroll 0 0 #FFFFFF;
        border: 1px solid #D7CBC1;
        color: #000000;
        font-size: 12px;
        line-height: 20px;
        list-style: none outside none;
        margin: 10px 2% 0 1%;
        padding: 1px;
    }
    .tag_list h5
    {
        background: none repeat scroll 0 0 #E0DBD3;
        color: #47381C;
        font-size: 12px;
        height: 24px;
        line-height: 24px;
        padding: 0 5px;
        margin: 0;
    }
    .tag_list h5 a
    {
        color: #47381C;
    }
    .classify
    {
        margin: 10px 0;
        padding: 4px 12px 8px;
    }
    .classify a
    {
        margin-right: 20px;
        white-space: nowrap;
    }
</style>
<div class="tag_list">
    <h5>
        <a href="http://www.csdn.net/tag/" target="_blank">核心技术类目</a></h5>
    <div class="classify">
<a title="全部主题" href="http://www.csdn.net/tag" target="_blank" onclick="LogClickCount(this,336);">全部主题</a>
<a title="Hadoop" href="http://g.csdn.net/5272865" target="_blank" onclick="LogClickCount(this,336);">Hadoop</a>
<a title="AWS" href="http://g.csdn.net/5272866" target="_blank" onclick="LogClickCount(this,336);">AWS</a>
<a title="移动游戏" href="http://g.csdn.net/5272870" target="_blank" onclick="LogClickCount(this,336);">移动游戏</a>
<a title="Java" href="http://g.csdn.net/5272871" target="_blank" onclick="LogClickCount(this,336);">Java</a>
<a title="Android" href="http://g.csdn.net/5272872" target="_blank" onclick="LogClickCount(this,336);">Android</a>
<a title="iOS" href="http://g.csdn.net/5272873" target="_blank" onclick="LogClickCount(this,336);">iOS</a>
<a title="Swift" href="http://g.csdn.net/5272868" target="_blank" onclick="LogClickCount(this,336);">Swift</a>
<a title="智能硬件" href="http://g.csdn.net/5272869" target="_blank" onclick="LogClickCount(this,336);">智能硬件</a>
<a title="Docker" href="http://g.csdn.net/5272867" target="_blank" onclick="LogClickCount(this,336);">Docker</a>
<a title="OpenStack" href="http://g.csdn.net/5272925" target="_blank" onclick="LogClickCount(this,336);">OpenStack</a>
<a title="VPN" href="http://www.csdn.net/tag/vpn" target="_blank" onclick="LogClickCount(this,336);">VPN</a>
<a title="Spark" href="http://g.csdn.net/5272924" target="_blank" onclick="LogClickCount(this,336);">Spark</a>
<a title="ERP" href="http://www.csdn.net/tag/erp" target="_blank" onclick="LogClickCount(this,336);">ERP</a>
<a title="IE10" href="http://www.csdn.net/tag/ie10" target="_blank" onclick="LogClickCount(this,336);">IE10</a>
<a title="Eclipse" href="http://www.csdn.net/tag/eclipse" target="_blank" onclick="LogClickCount(this,336);">Eclipse</a>
<a title="CRM" href="http://www.csdn.net/tag/crm" target="_blank" onclick="LogClickCount(this,336);">CRM</a>
<a title="JavaScript" href="http://www.csdn.net/tag/javascript" target="_blank" onclick="LogClickCount(this,336);">JavaScript</a>
<a title="数据库" href="http://www.csdn.net/tag/数据库" target="_blank" onclick="LogClickCount(this,336);">数据库</a>
<a title="Ubuntu" href="http://www.csdn.net/tag/ubuntu" target="_blank" onclick="LogClickCount(this,336);">Ubuntu</a>
<a title="NFC" href="http://www.csdn.net/tag/nfc" target="_blank" onclick="LogClickCount(this,336);">NFC</a>
<a title="WAP" href="http://www.csdn.net/tag/wap" target="_blank" onclick="LogClickCount(this,336);">WAP</a>
<a title="jQuery" href="http://www.csdn.net/tag/jquery" target="_blank" onclick="LogClickCount(this,336);">jQuery</a>
<a title="BI" href="http://www.csdn.net/tag/bi" target="_blank" onclick="LogClickCount(this,336);">BI</a>
<a title="HTML5" href="http://www.csdn.net/tag/html5" target="_blank" onclick="LogClickCount(this,336);">HTML5</a>
<a title="Spring" href="http://www.csdn.net/tag/spring" target="_blank" onclick="LogClickCount(this,336);">Spring</a>
<a title="Apache" href="http://www.csdn.net/tag/apache" target="_blank" onclick="LogClickCount(this,336);">Apache</a>
<a title=".NET" href="http://www.csdn.net/tag/.net" target="_blank" onclick="LogClickCount(this,336);">.NET</a>
<a title="API" href="http://www.csdn.net/tag/api" target="_blank" onclick="LogClickCount(this,336);">API</a>
<a title="HTML" href="http://www.csdn.net/tag/html" target="_blank" onclick="LogClickCount(this,336);">HTML</a>
<a title="SDK" href="http://www.csdn.net/tag/sdk" target="_blank" onclick="LogClickCount(this,336);">SDK</a>
<a title="IIS" href="http://www.csdn.net/tag/iis" target="_blank" onclick="LogClickCount(this,336);">IIS</a>
<a title="Fedora" href="http://www.csdn.net/tag/fedora" target="_blank" onclick="LogClickCount(this,336);">Fedora</a>
<a title="XML" href="http://www.csdn.net/tag/xml" target="_blank" onclick="LogClickCount(this,336);">XML</a>
<a title="LBS" href="http://www.csdn.net/tag/lbs" target="_blank" onclick="LogClickCount(this,336);">LBS</a>
<a title="Unity" href="http://www.csdn.net/tag/unity" target="_blank" onclick="LogClickCount(this,336);">Unity</a>
<a title="Splashtop" href="http://www.csdn.net/tag/splashtop" target="_blank" onclick="LogClickCount(this,336);">Splashtop</a>
<a title="UML" href="http://www.csdn.net/tag/uml" target="_blank" onclick="LogClickCount(this,336);">UML</a>
<a title="components" href="http://www.csdn.net/tag/components" target="_blank" onclick="LogClickCount(this,336);">components</a>
<a title="Windows Mobile" href="http://www.csdn.net/tag/windowsmobile" target="_blank" onclick="LogClickCount(this,336);">Windows Mobile</a>
<a title="Rails" href="http://www.csdn.net/tag/rails" target="_blank" onclick="LogClickCount(this,336);">Rails</a>
<a title="QEMU" href="http://www.csdn.net/tag/qemu" target="_blank" onclick="LogClickCount(this,336);">QEMU</a>
<a title="KDE" href="http://www.csdn.net/tag/kde" target="_blank" onclick="LogClickCount(this,336);">KDE</a>
<a title="Cassandra" href="http://www.csdn.net/tag/cassandra" target="_blank" onclick="LogClickCount(this,336);">Cassandra</a>
<a title="CloudStack" href="http://www.csdn.net/tag/cloudstack" target="_blank" onclick="LogClickCount(this,336);">CloudStack</a>
<a title="FTC" href="http://www.csdn.net/tag/ftc" target="_blank" onclick="LogClickCount(this,336);">FTC</a>
<a title="coremail" href="http://www.csdn.net/tag/coremail" target="_blank" onclick="LogClickCount(this,336);">coremail</a>
<a title="OPhone " href="http://www.csdn.net/tag/ophone " target="_blank" onclick="LogClickCount(this,336);">OPhone </a>
<a title="CouchBase" href="http://www.csdn.net/tag/couchbase" target="_blank" onclick="LogClickCount(this,336);">CouchBase</a>
<a title="云计算" href="http://www.csdn.net/tag/云计算" target="_blank" onclick="LogClickCount(this,336);">云计算</a>
<a title="iOS6" href="http://www.csdn.net/tag/iOS6" target="_blank" onclick="LogClickCount(this,336);">iOS6</a>
<a title="Rackspace " href="http://www.csdn.net/tag/rackspace " target="_blank" onclick="LogClickCount(this,336);">Rackspace </a>
<a title="Web App" href="http://www.csdn.net/tag/webapp" target="_blank" onclick="LogClickCount(this,336);">Web App</a>
<a title="SpringSide" href="http://www.csdn.net/tag/springside" target="_blank" onclick="LogClickCount(this,336);">SpringSide</a>
<a title="Maemo" href="http://www.csdn.net/tag/maemo" target="_blank" onclick="LogClickCount(this,336);">Maemo</a>
<a title="Compuware" href="http://www.csdn.net/tag/compuware" target="_blank" onclick="LogClickCount(this,336);">Compuware</a>
<a title="大数据" href="http://www.csdn.net/tag/大数据" target="_blank" onclick="LogClickCount(this,336);">大数据</a>
<a title="aptech" href="http://www.csdn.net/tag/aptech" target="_blank" onclick="LogClickCount(this,336);">aptech</a>
<a title="Perl" href="http://www.csdn.net/tag/perl" target="_blank" onclick="LogClickCount(this,336);">Perl</a>
<a title="Tornado" href="http://www.csdn.net/tag/tornado" target="_blank" onclick="LogClickCount(this,336);">Tornado</a>
<a title="Ruby" href="http://www.csdn.net/tag/ruby" target="_blank" onclick="LogClickCount(this,336);">Ruby</a>
<a title="Hibernate" href="http://www.csdn.net/hibernate" target="_blank" onclick="LogClickCount(this,336);">Hibernate</a>
<a title="ThinkPHP" href="http://www.csdn.net/tag/thinkphp" target="_blank" onclick="LogClickCount(this,336);">ThinkPHP</a>
<a title="HBase" href="http://www.csdn.net/tag/hbase" target="_blank" onclick="LogClickCount(this,336);">HBase</a>
<a title="Pure" href="http://www.csdn.net/tag/pure" target="_blank" onclick="LogClickCount(this,336);">Pure</a>
<a title="Solr" href="http://www.csdn.net/tag/solr" target="_blank" onclick="LogClickCount(this,336);">Solr</a>
<a title="Angular" href="http://www.csdn.net/tag/angular" target="_blank" onclick="LogClickCount(this,336);">Angular</a>
<a title="Cloud Foundry" href="http://www.csdn.net/tag/cloudfoundry" target="_blank" onclick="LogClickCount(this,336);">Cloud Foundry</a>
<a title="Redis" href="http://www.csdn.net/tag/redis" target="_blank" onclick="LogClickCount(this,336);">Redis</a>
<a title="Scala" href="http://www.csdn.net/tag/scala" target="_blank" onclick="LogClickCount(this,336);">Scala</a>
<a title="Django" href="http://www.csdn.net/tag/django" target="_blank" onclick="LogClickCount(this,336);">Django</a>
<a title="Bootstrap" href="http://www.csdn.net/tag/bootstrap" target="_blank" onclick="LogClickCount(this,336);">Bootstrap</a>
    </div>
</div>

<div id="pop_win" style="display:none ;position: absolute; z-index: 10000; border: 1px solid rgb(220, 220, 220); top: 222.5px; left: 630px; opacity: 1; background: none 0px 0px repeat scroll rgb(255, 255, 255);">
    
</div>
<div id="popup_mask"></div>
<style>
    #popup_mask
    {
        position: absolute;
        width: 100%;
        height: 100%;
        background: #000;
        z-index: 9999;
        left: 0px;
        top: 0px;
        opacity: 0.3;
        filter: alpha(opacity=30);
        display: none;
    }

</style>




<script type="text/javascript">
    $(function(){
        setTimeout(function(){
            $(".comment_body:contains('回复')").each(function(index,item){
                var u=$(this).text().split('：')[0].toString().replace("回复","")
                var thisComment=$(this);
                if(u)
                {
                    $.getJSON("https://passport.csdn.net/get/nick?callback=?", {users: u}, function(a) {
                        if(a!=null&&a.data!=null&&a.data.length>0)
                        {
                            nick=a.data[0].n; 
                            if(u!=nick)
                            {
                                thisComment.text(thisComment.text().replace(u,nick));  
                            }
                        }       
                    });  
                }
            });
        },200);  
        
        setTimeout(function(){
            $("a img[src='http://js.tongji.linezing.com/stats.gif']").parent().css({"position":"absolute","left":"50%"});
        },300);
    });

    function loginbox(){
        var $logpop=$("#pop_win");
        $logpop.html('<iframe src="https://passport.csdn.net/account/loginbox?service=http://static.blog.csdn.net/callback.htm" frameborder="0" height="600" width="400" scrolling="no"></iframe>');

        $('#popup_mask').css({
            opacity: 0.5,
            width: $( document ).width() + 'px',
            height:  $( document ).height() + 'px'
        });
        $('#popup_mask').css("display","block");
 
        $logpop.css( {
            top: ($( window ).height() - $logpop.height())/ 2  + $( window 
       ).scrollTop() + 'px',
            left:($( window ).width() - $logpop.width())/ 2
        } );
 
        setTimeout( function () {
            $logpop.show();
            $logpop.css( {
                opacity: 1
            } );
        }, 200 );
 
        $('#popup_mask').unbind("click");
        $('#popup_mask').bind("click", function(){
            $('#popup_mask').hide();
            var $clopop = $("#pop_win");
            $("#common_ask_div_sc").css("display","none");
            $clopop.css( {
                opacity: 0
            } );
            setTimeout( function () {
                $clopop.hide();
            }, 350 );
            return false;
        });
    }    

</script>
                        <div class="clear">
                        </div>
                    </div>                   
                
            </div>
            <div id="side">
    <div class="side">
<div class="panel" id="panel_Search">
    <ul class="panel_head"><span>文章搜索</span></ul>
    <ul class="panel_body">
        <form id="frmSearch" action="http://so.csdn.net/search" class="form_search" target="_blank">
        <span><input id="inputSearch" type="text" class="blogsearch" title="请输入关键字" /></span>
        <input id="btnSubmit" type="button" value="搜索" title="search in blog" />
        <input type="hidden" name="q" id="inputQ" />
        <input type="hidden" name="t" value="blog" />
        <a id="btnSearchBlog" target="_blank"></a>
        </form>
    </ul>
</div>

<script type="text/javascript">
    $(function () {
        $("#btnSubmit").click(function () {           
            search();
        });

        $("#frmSearch").submit(function () {
            search();
            return false;
        });

        function search()
        {
            var url = "http://so.csdn.net/so/search/s.do?q=" + encodeURIComponent($("#inputSearch").val()) + "&u=" + username + "&t=blog";
            window.location.href = url;
        }   
    });
</script><div id="panel_Profile" class="panel">
<ul class="panel_head"><span>个人资料</span></ul>
<ul class="panel_body profile">
<div id="blog_userface">
    <a href="http://my.csdn.net/smking" target="_blank">
    <img src="http://avatar.csdn.net/C/5/9/1_smking.jpg" title="访问我的空间" style="max-width:90%"/>
    </a>
    <br />
    <span><a href="http://my.csdn.net/smking" class="user_name" target="_blank">smking</a></span>
</div>
<div class="interact">
<a href="javascript:void(0);" class="attent" id="span_add_follow" title="[加关注]" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_guanzhu'])"></a>

 <a href="javascript:void(0);" class="letter"  title="[发私信]" onclick="window.open('http://msg.csdn.net/letters/model?receiver=smking','_blank','height=350,width=700');_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_sixin'])"></a>  
</div>
<div id="blog_medal">
                <div id="bms_box">
                                            <a  target="_blank">
                                                    <img src="http://c.csdnimg.cn/jifen/images/xunzhang/xunzhang/chizhiyiheng.png" onmouseover="m_over_m(this,4)" onmouseout="m_out_m()" alt="1" >
                                            </a>
               </div>
</div>
<ul id="blog_rank">
    <li>访问：<span>491432次</span></li>
    <li>积分：<span>6497</span> </li>    
    <li >等级： <span style="position:relative;display:inline-block;z-index:1" >
            <img src="http://c.csdnimg.cn/jifen/images/xunzhang/jianzhang/blog6.png" alt="" style="vertical-align: middle;" id="leveImg">
            <div id="smallTittle" style=" position: absolute;  left: -24px;  top: 25px;  text-align: center;  width: 101px;  height: 32px;  background-color: #fff;  line-height: 32px;  border: 2px #DDDDDD solid;  box-shadow: 0px 2px 2px rgba (0,0,0,0.1);  display: none;   z-index: 999;">
            <div style="left: 42%;  top: -8px;  position: absolute;  width: 0;  height: 0;  border-left: 10px solid transparent;  border-right: 10px solid transparent;  border-bottom: 8px solid #EAEAEA;"></div>
            积分：6497 </div>
        </span>  </li>
    <li>排名：<span>第1459名</span></li>
</ul>
<ul id="blog_statistics">
    <li>原创：<span>132篇</span></li>
    <li>转载：<span>163篇</span></li>
    <li>译文：<span>0篇</span></li>
    <li>评论：<span>126条</span></li>
</ul>
</ul>
</div>



<div id="panel_Category" class="panel">
<ul class="panel_head"><span>文章分类</span></ul>
<ul class="panel_body">
             <li>
                <a href="http://blog.csdn.net/smking/article/category/585876" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">技术</a><span>(232)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/smking/article/category/585875" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">生活</a><span>(12)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/smking/article/category/1092775" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">ffmpeg</a><span>(1)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/smking/article/category/1092776" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">移植</a><span>(1)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/smking/article/category/1308291" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">iOS</a><span>(39)</span>
            </li>
             <li>
                <a href="http://blog.csdn.net/smking/article/category/1308292" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">Android</a><span>(2)</span>
            </li>
</ul>
</div><div id="panel_Archive" class="panel">
<ul class="panel_head"><span>文章存档</span></ul>
<ul class="panel_body">
<div id="archive_list">
<!--归档统计-->
<li><a href="http://blog.csdn.net/smking/article/month/2015/05">2015年05月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2015/02">2015年02月</a><span>(7)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2015/01">2015年01月</a><span>(4)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2014/12">2014年12月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2014/10">2014年10月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2014/09">2014年09月</a><span>(9)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2014/08">2014年08月</a><span>(16)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2014/07">2014年07月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2014/06">2014年06月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2014/05">2014年05月</a><span>(5)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2014/04">2014年04月</a><span>(4)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2014/03">2014年03月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2014/01">2014年01月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/12">2013年12月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/10">2013年10月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/09">2013年09月</a><span>(3)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/08">2013年08月</a><span>(3)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/07">2013年07月</a><span>(6)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/06">2013年06月</a><span>(6)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/05">2013年05月</a><span>(14)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/04">2013年04月</a><span>(11)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/03">2013年03月</a><span>(28)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/02">2013年02月</a><span>(10)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2013/01">2013年01月</a><span>(20)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2012/12">2012年12月</a><span>(37)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2012/11">2012年11月</a><span>(4)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2012/10">2012年10月</a><span>(10)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2012/09">2012年09月</a><span>(9)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2012/08">2012年08月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2012/07">2012年07月</a><span>(6)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2012/06">2012年06月</a><span>(10)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2012/05">2012年05月</a><span>(9)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2012/03">2012年03月</a><span>(5)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2011/06">2011年06月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2011/03">2011年03月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2010/05">2010年05月</a><span>(4)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2010/04">2010年04月</a><span>(3)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2010/03">2010年03月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2010/02">2010年02月</a><span>(9)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2009/12">2009年12月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2009/11">2009年11月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2009/09">2009年09月</a><span>(4)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2009/08">2009年08月</a><span>(13)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2009/07">2009年07月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/smking/article/month/2008/09">2008年09月</a><span>(4)</span></li>
</div>
</ul>
</div>
<div id="hotarticls" class="panel">
<ul class="panel_head">
    <span>       
阅读排行    </span>
</ul>

<ul class="panel_body itemlist">
<li>
<a href="/smking/article/details/8148702" title="iOS设备的硬件适配 (关于armv6, armv7, armv7s 个人觉得说得比较清楚)">iOS设备的硬件适配 (关于armv6, armv7, armv7s 个人觉得说得比较清楚)</a><span>(18991)</span>
</li>
<li>
<a href="/smking/article/details/8590547" title="&lt;iOS&gt;关于viewWithTag的一点说明">&lt;iOS&gt;关于viewWithTag的一点说明</a><span>(12266)</span>
</li>
<li>
<a href="/smking/article/details/7792104" title="关于Zbar和ZXing这两个无比强大的二维码和条形码识别工具">关于Zbar和ZXing这两个无比强大的二维码和条形码识别工具</a><span>(11276)</span>
</li>
<li>
<a href="/smking/article/details/7310178" title="iOS上二维码和一维码识别系列一">iOS上二维码和一维码识别系列一</a><span>(11141)</span>
</li>
<li>
<a href="/smking/article/details/7569990" title="ios 根据手势放大或缩小图片">ios 根据手势放大或缩小图片</a><span>(10579)</span>
</li>
<li>
<a href="/smking/article/details/8314656" title="&lt;iOS&gt;响应事件传递, nextResponder研究">&lt;iOS&gt;响应事件传递, nextResponder研究</a><span>(8848)</span>
</li>
<li>
<a href="/smking/article/details/8268206" title="&lt;Android&gt; Failed to pull selection 解决">&lt;Android&gt; Failed to pull selection 解决</a><span>(8116)</span>
</li>
<li>
<a href="/smking/article/details/18363163" title="Choose a destination with a supported architecture in order to run on this device.">Choose a destination with a supported architecture in order to run on this device.</a><span>(8095)</span>
</li>
<li>
<a href="/smking/article/details/9342899" title="通过崩溃trace来查找问题原因">通过崩溃trace来查找问题原因</a><span>(7969)</span>
</li>
<li>
<a href="/smking/article/details/8424245" title="&lt; iOS &gt;CABasicAnimation用法">&lt; iOS &gt;CABasicAnimation用法</a><span>(6871)</span>
</li>
</ul>
</div>
<div id="hotarticls2" class="panel">
<ul class="panel_head"><span>评论排行</span></ul>
<ul class="panel_body itemlist">
<li>
<a href="/smking/article/details/7310178" title="iOS上二维码和一维码识别系列一">iOS上二维码和一维码识别系列一</a><span>(18)</span>
</li>
<li>
<a href="/smking/article/details/7325790" title="在iOS上使用ffmepg">在iOS上使用ffmepg</a><span>(14)</span>
</li>
<li>
<a href="/smking/article/details/7373787" title="写网络视频监视器中的总结 (一)">写网络视频监视器中的总结 (一)</a><span>(10)</span>
</li>
<li>
<a href="/smking/article/details/8148702" title="iOS设备的硬件适配 (关于armv6, armv7, armv7s 个人觉得说得比较清楚)">iOS设备的硬件适配 (关于armv6, armv7, armv7s 个人觉得说得比较清楚)</a><span>(7)</span>
</li>
<li>
<a href="/smking/article/details/18363163" title="Choose a destination with a supported architecture in order to run on this device.">Choose a destination with a supported architecture in order to run on this device.</a><span>(7)</span>
</li>
<li>
<a href="/smking/article/details/7569990" title="ios 根据手势放大或缩小图片">ios 根据手势放大或缩小图片</a><span>(5)</span>
</li>
<li>
<a href="/smking/article/details/7792104" title="关于Zbar和ZXing这两个无比强大的二维码和条形码识别工具">关于Zbar和ZXing这两个无比强大的二维码和条形码识别工具</a><span>(4)</span>
</li>
<li>
<a href="/smking/article/details/7310427" title="iOS上二维码和一维码识别系列二">iOS上二维码和一维码识别系列二</a><span>(4)</span>
</li>
<li>
<a href="/smking/article/details/7561688" title="写网络视频监视器中的总结（二）">写网络视频监视器中的总结（二）</a><span>(3)</span>
</li>
<li>
<a href="/smking/article/details/39010067" title="ＳＤＫ开发中如何去捕获系统的didReceiveLocalNotification以及didReceiveRemoteNotification通知">ＳＤＫ开发中如何去捕获系统的didReceiveLocalNotification以及didReceiveRemoteNotification通知</a><span>(3)</span>
</li>
</ul>
</div>
<div id="homepageArticles" class="panel tracking-ad" data-mod="popu_4">
<ul class="panel_head"><span>推荐文章</span></ul>
<ul class="panel_body" id="ad_commend"></ul>
</div>
<script type="text/javascript">
 new Ad(12, 'ad_commend');
</script><div id="newcomments" class="panel">
<ul class="panel_head"><span>最新评论</span></ul>
<ul class="panel_body itemlist">
    <li>
   
         <a href="/smking/article/details/38682755#comments">Ａ界面presentＢ界面， 需要Ｂ界面背景透明， 能透过底部看到Ａ界面</a>
    <p style="margin:0px;"><a href="/ToBe_One" class="user_name">ToBe_One</a>:
一把幸酸泪，这个问题憋死我了
    </p>
    </li>
    <li>
   
         <a href="/smking/article/details/38682755#comments">Ａ界面presentＢ界面， 需要Ｂ界面背景透明， 能透过底部看到Ａ界面</a>
    <p style="margin:0px;"><a href="/ToBe_One" class="user_name">ToBe_One</a>:
楼主我给你跪了，第三条一语惊醒梦中人啊，呜呜呜。。。
    </p>
    </li>
    <li>
   
         <a href="/smking/article/details/8269355#comments">【Android】拷贝文件到另一个目录下</a>
    <p style="margin:0px;"><a href="/lucasmaluping" class="user_name">lucasmaluping</a>:
请问房东，复制单个文件的时间为什么要判断当文件不存在时？？？
    </p>
    </li>
    <li>
   
         <a href="/smking/article/details/8768512#comments">ARC使用说明</a>
    <p style="margin:0px;"><a href="/zzzhangdong" class="user_name">zzzhangdong</a>:
CGContextSetStrokeColorWithColor(ctx, .CGColor);这样...
    </p>
    </li>
    <li>
   
         <a href="/smking/article/details/8314656#comments">&lt;iOS&gt;响应事件传递, nextResponder研究</a>
    <p style="margin:0px;"><a href="/smking" class="user_name">smking</a>:
@dzxylb:不好意思， 我实在没有看明白你说的问题。
    </p>
    </li>
    <li>
   
         <a href="/smking/article/details/8314656#comments">&lt;iOS&gt;响应事件传递, nextResponder研究</a>
    <p style="margin:0px;"><a href="/dzxylb" class="user_name">dzxylb</a>:
我在tableview的cell中使用这个方法，为什么第一次调用的时候获取的父viewcontrol...
    </p>
    </li>
    <li>
   
         <a href="/smking/article/details/8424851#comments">&lt;iOS&gt; 谈谈iOS Animation</a>
    <p style="margin:0px;"><a href="/chao24642" class="user_name">chao24642</a>:
挺棒的，学习了
    </p>
    </li>
    <li>
   
         <a href="/smking/article/details/42879649#comments">使用真机调试时的问题。</a>
    <p style="margin:0px;"><a href="/xiguanqinni" class="user_name">xiguanqinni</a>:
沈先生我是邹琦，最近联系不上你，是不是换号了呀
    </p>
    </li>
    <li>
   
         <a href="/smking/article/details/38925585#comments">iBeacon行为分析</a>
    <p style="margin:0px;"><a href="/liang_ke_ke" class="user_name">liang_ke_ke</a>:
你好，最近也在做Ibeacon的小项目，我们测试发现项目在iPhone 6plus上面运行的时候，熄...
    </p>
    </li>
    <li>
   
         <a href="/smking/article/details/8296223#comments">&lt;iOS&gt;网络编程（四）SOAP, WSDL, Web Service</a>
    <p style="margin:0px;"><a href="/Gmonday" class="user_name">Gmonday</a>:
总结的不错
    </p>
    </li>
</ul>
</div>
    </div>
    <div class="clear">
    </div>
</div>

            <div class="clear">
            </div>
        </div>
        

<script type="text/javascript" src="http://c.csdnimg.cn/rabbit/cnick/cnick.js"></script>
<script type="text/javascript" src="http://static.blog.csdn.net/scripts/newblog.min.js"></script>


<script type="text/javascript" src="http://medal.blog.csdn.net/showblogmedal.ashx?blogid=429771"></script>
<script type="text/javascript" src="http://static.blog.csdn.net/scripts/JavaScript1.js"></script>

    <script type="text/javascript" src="http://passport.csdn.net/content/loginbox/login.js"></script>
<script type="text/javascript">document.write("<img src=http://counter.csdn.net/pv.aspx?id=24 border=0 width=0 height=0>");</script>
<script type="text/javascript" src="http://www.csdn.net/ui/scripts/Csdn/counter.js"></script>
<script type="text/javascript" src="http://ad.csdn.net/scripts/ad-blog.js"></script>
<script type="text/javascript" src="http://zz.csdn.net/js/count.js"></script>
<script type="text/javascript">
    $(function () {
        function __get_code_toolbar(snippet_id) {
            return $("<a href='https://code.csdn.net/snippets/"
                    + snippet_id
                    + "' target='_blank' title='在CODE上查看代码片' style='text-indent:0;'><img src='https://code.csdn.net/assets/CODE_ico.png' width=12 height=12 alt='在CODE上查看代码片' style='position:relative;top:1px;left:2px;'/></a>"
                    + "<a href='https://code.csdn.net/snippets/"
                    + snippet_id
                    + "/fork' target='_blank' title='派生到我的代码片'  style='text-indent:0;'><img src='https://code.csdn.net/assets/ico_fork.svg' width=12 height=12 alt='派生到我的代码片' style='position:relative;top:2px;left:2px;'/></a>");
        }
        
        $("[code_snippet_id]").each(function () {
            __s_id = $(this).attr("code_snippet_id");
            if (__s_id != null && __s_id != "" && __s_id != 0 && parseInt(__s_id) > 70020) {
                __code_tool = __get_code_toolbar(__s_id);
                $(this).prev().find(".tools").append(__code_tool);
            }
        });
    });
</script>




    </div>
      <!--new top-->
    
    <script id="csdn-toolbar-id" btnId="header_notice_num" wrapId="note1" count="5" subCount="5" type="text/javascript" src="http://static.csdn.net/public/common/toolbar/js/toolbar.js"></script>     <!--new top-->
   
    <link href="http://c.csdnimg.cn/comm_ask/css/ask_float_block.css" type="text/css" rel="stylesheet" />
    <script language='JavaScript' type='text/javascript' src='http://c.csdnimg.cn/comm_ask/js/libs/wmd.js'></script>
    <script language='JavaScript' type='text/javascript' src='http://c.csdnimg.cn/comm_ask/js/libs/showdown.js'></script>
    <script language='JavaScript' type='text/javascript' src='http://c.csdnimg.cn/comm_ask/js/libs/prettify.js'></script>
    <script language='JavaScript' type='text/javascript' src='http://c.csdnimg.cn/comm_ask/js/apps/ask_float_block.js'></script>

</body>
</html>
